<template>
	<view class="warranty">
		<view class="tab">
			<view class="f16" :class="[isActive ==3?'acitve':'']" @click="handTab(3)">在保</view>
			<view class="f16" :class="[isActive ==4?'acitve':'']" @click="handTab(4)">过保</view>
		</view>
		<view class="inwarranty" v-if="isActive==3">
			<view class="vailCard" v-for="item in inTimeList" :key="item.wcNo">
				<view class="row">
					<view class="right">
						<icon class="iconfont iconshijian hascolor" type="" />
						{{item.svcDate? item.svcDate.split(' ')[0]:'' }}
						</view>
					<view class="left">
						{{item.svcDate?item.svcDate.split(' ')[1].split('.')[0].substr(0,5):''}}
					</view>
				</view>
				<view  class="row">
					<view class="right txt">{{item.liaison}}</view>
					<view class="left">{{item.liaisonPhone}}</view>
				</view>
				<view class="row address">
					{{item.svcPosition}}
				</view>
				<view class="row">
					<view class="right detil" @click="jumpDetail(item.wcId)">详情</view>
					<view class="left">{{item.warrantyEndDate ? item.warrantyEndDate.split(' ')[0]:''}}</view>
				</view>
				<view class="showButton f18">
					保修期还有：{{item.warrantyPeriod}}天
				</view>
			</view>
			<view class="nullbox" v-if="inTimeList.length == 0">
				没有保修卡记录
			</view>
		</view>
		<view class="inwarranty" v-else>
			<view class="vailCard" v-for="item in unTimeList" :key="item.wcNo">
				<view class="row">
					<view class="right">
						<icon class="iconfont iconshijian hascolor" type="" />
						{{item.svcDate? item.svcDate.split(' ')[0]:'' }}
						</view>
					<view class="left">
						{{item.svcDate?item.svcDate.split(' ')[1].split('.')[0].substr(0,5):''}}
					</view>
				</view>
				<view  class="row">
					<view class="right txt">{{item.liaison}}</view>
					<view class="left">{{item.liaisonPhone}}</view>
				</view>
				<view class="row address">
					{{item.svcPosition}}
				</view>
				<view class="row">
					<view class="right detil" @click="jumpDetail(item.wcId)">详情</view>
					<view class="left">{{item.warrantyEndDate ? item.warrantyEndDate.split(' ')[0]:''}}</view>
				</view>
				<view class="showButton f18 ed">
					已过期
				</view>
			</view>
			<view class="nullbox" v-if="unTimeList.length == 0">
				没有保修卡记录
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
		},
		data() {
			return {
				isActive:3,
				inTimeList:[],
				unTimeList:[]
			}
		},
		onLoad() {
			this.getCardList(3)
		},
		methods: {
			handTab(num){
				this.isActive=num
				this.getCardList(num)
			},
			jumpDetail(wcId){
				uni.navigateTo({
					url:"../cardDetails/cardDetails_s?type=1&wcId="+wcId+'&isActive='+this.isActive
				})
			},
			getCardList(num){
				this.postApi('s_list','POST',{
				data:{status:num},
				loading:true}).then(res=>{
					console.log('ressss',res)
					if(num ==3){
						this.inTimeList = res.data
					}else{
						this.unTimeList = res.data
					}
				})
			}
		}
	}
</script>

<style lang="less">
	@import '@/common/common.less';
	.warranty{
		background-color: #eeeeee;
		display: flex;
		flex-direction: column;
		position: relative;
		height: 100%;
		.tab{
			height: 104rpx;
			display: flex;
			justify-content: space-evenly;
			align-items: center;
			background-color: #ffffff;
			position: fixed;
			top: 0;
			width: 100%;
			z-index: 1;
			.acitve{
				color: @primary-color;
			}
		}
		.inwarranty{
			width: 95%;
			margin: 0 auto;
			height: calc( 100% - 104rpx) ;
			margin-top: 104rpx;
			.nullbox{
				text-align: center;
				margin-top:200rpx;
				color: #555555;
			}
			.vailCard{
				margin-top: 17rpx;
				background-color: #FFFFFF;
				border-radius: 10rpx;
				padding: 23rpx 30rpx;
				color: #555555;
				.row{
					position: relative;
					display: flex;
					justify-content: space-between;
					margin-bottom: 22rpx;
					align-items: center;
					.right{
						.iconfont{
							margin-right: 30rpx;
						}
						.hascolor{
							color: @primary-color;
						}
					}
					.right.txt{
						margin-left: 60rpx;
					}
					.right.detil{
						color: @primary-color;
						margin-left: 60rpx;
					}
					.left{
						margin-top:5px
					}
				}
				.row.address{
					margin-left: 60rpx;
				}
				.showButton{
					height: 88rpx;
					line-height: 88rpx;
					background-color: @primary-color;
					text-align: center;
					font-weight: bold;
					color: #FFFFFF;
					border-radius: 10rpx;
				}
				.ed{
					background-color: #aaaaaa;
				}
			}
		}
	}
</style>
